package com.nuoniu.sibanyun.controller.expenses;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.crm.call.dto.CrmCallAgentSearchDto;
import com.nuoniu.sibanyun.entity.expenses.dto.ExpensesAccountSearchDto;
import com.nuoniu.sibanyun.service.expenses.IExpensesAccountService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * <p>
 * 费用中心-账户管理 前端控制器
 * </p>
 *
 * @author 白强
 * @since 2022-05-06
 */
@RestController
@RequestMapping("/expenses/account")
@Api(value="费用中心-账户管理 ",tags={"费用中心-账户管理"})
public class ExpensesAccountController extends BaseController {

    @Autowired
    private IExpensesAccountService accountService;

    @PostMapping("pageList")
    @ApiOperation(value = "分页查询 账户(系统)")
    @PreAuthorize("'system' == authentication.principal ")
    public HttpResult pageList(@RequestBody ExpensesAccountSearchDto accountSearchDto) {
        return HttpResult.ok(accountService.pageList(accountSearchDto));
    }


    @GetMapping("getByCompany")
    @ApiOperation(value = "获取当前租户账户信息")
    public HttpResult getByCompany() {
        UserInfo userInfo = UserThreadLocal.get();
        return HttpResult.ok(accountService.getByCompany(userInfo.getCompanyId()));
    }

    @PostMapping("addDeposit")
    @ApiOperation(value = "缴纳保证金")
    public HttpResult addDeposit(BigDecimal deposit) {
        accountService.addDeposit(deposit);
        return HttpResult.ok();
    }

}
